export default {
  namespaced:true,
  
  // 数据
  state:() => ({
    // 读取本地收货地址，初始化address对象
    address:JSON.parse(uni.getStorageSync('address') || '{}'),
  }),
  
  // 方法
  mutations:{
    updateAddress(state,address) {
      state.address = address
     this.commit('m_user/saveAddressToStorage')
    },
    // 把address存储到本地
    saveAddressToStorage(state) {
      uni.setStorageSync('address',JSON.stringify(state.address))
    }
  },
  // 数据包装器
  getters:{
    addStr(state) {
      if (!state.address.provinceName) return ''
      return state.address.provinceName + state.address.cityName + state.address.countyName + state.address.detailInfo
    }
  }
}